package com.tjec.project.mdmSynchronous.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.mdmSynchronous.domain.SysAdministrative;
import com.tjec.project.mdmSynchronous.service.ISysAdministrativeService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 行政组织架构Controller
 * 
 * @author villwang
 * @date 2020-05-13
 */
@RestController
@RequestMapping("/system/administrative")
public class SysAdministrativeController extends BaseController
{
    @Autowired
    private ISysAdministrativeService sysAdministrativeService;

    /**
     * 查询行政组织架构列表
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAdministrative sysAdministrative)
    {
        startPage();
        List<SysAdministrative> list = sysAdministrativeService.selectSysAdministrativeList(sysAdministrative);
        return getDataTable(list);
    }

    /**
     * 导出行政组织架构列表
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:export')")
    @Log(title = "行政组织架构", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysAdministrative sysAdministrative)
    {
        List<SysAdministrative> list = sysAdministrativeService.selectSysAdministrativeList(sysAdministrative);
        ExcelUtil<SysAdministrative> util = new ExcelUtil<SysAdministrative>(SysAdministrative.class);
        return util.exportExcel(list, "administrative");
    }

    /**
     * 获取行政组织架构详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(sysAdministrativeService.selectSysAdministrativeByGuid(guid));
    }

    /**
     * 新增行政组织架构
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:add')")
    @Log(title = "行政组织架构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAdministrative sysAdministrative)
    {
        return toAjax(sysAdministrativeService.insertSysAdministrative(sysAdministrative));
    }

    /**
     * 修改行政组织架构
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:edit')")
    @Log(title = "行政组织架构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAdministrative sysAdministrative)
    {
        return toAjax(sysAdministrativeService.updateSysAdministrative(sysAdministrative));
    }

    /**
     * 删除行政组织架构
     */
    @PreAuthorize("@ss.hasPermi('system:administrative:remove')")
    @Log(title = "行政组织架构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(sysAdministrativeService.deleteSysAdministrativeByGuids(guids));
    }
}
